<?php

namespace Crm\Controller;

/**
 * InstallController.class控制器
 *
 * @author SoChishun <14507247@qq.com>
 * @version 1.0
 * @since 1.0.0 <2015-3-23> by SoChishun Added.
 */
class InstallController extends \Think\Controller {

    /**
     * index操作
     * @since 1.0.0 <2015-3-23> by SoChishun Added.
     */
    public function index() {
        !appfn_is_install() || die('系统已经安装过了.');
        // 第一步：安装初始账户
        $M = M();
        if ($M->table('tuser')->count('id') < 1) {
            $result = $M->table('tuser')->add(array('login_name' => 'superadmin', 'password' => 'superadmin!@#', 'user_type' => 'SUPERADMIN', 'role_id' => -1, 'state' => 1));
            if (false === $result) {
                die($M->getDbError());
            }
        }
        F('APP_IS_INSTALLED', true);
        redirect(U('Index/index'));
    }

}
